<?php
 
function pager_navigation($pager, $uri, $table = null)
{
	$navigation = '';
	if(is_null($table))
	{
		$tab = "";
	}
	else
	{
		$tab ='&tab='.$table;
	}
	
	if ($pager->haveToPaginate())
	{ 
		$uri .= (preg_match('/\?/', $uri) ? '&' : '?').'page=';
	 
		// First and previous page
		if ($pager->getPage() != 1)
		{
			$navigation .= link_to('<img align="absmiddle" src="/images/first.png"/>', $uri.'1'.$tab);
			$navigation .= link_to('<img align="absmiddle" src="/images/previous.png"/>', $uri.$pager->getPreviousPage().$tab).' ';
			//$navigation .= link_to(image_tag('/images/first.png', 'align=absmiddle'), $uri.'1'.$tab);
			//$navigation .= link_to(image_tag('/images/previous.png', 'align=absmiddle'), $uri.$pager->getPreviousPage().$tab).' ';
	    }
	 
	    // Pages one by one
		$links = array();
	    
		foreach($pager->getLinks() as $page)
	    {
			$links[] = link_to_unless($page == $pager->getPage(), $page, $uri.$page . $tab);
	    }
	    
	    $navigation .= join('  ', $links);
	 
	    // Next and last page
	    if($pager->getPage() != $pager->getLastPage())
	    {
	    	$navigation .= ' '.link_to('<img align="absmiddle" src="/images/next.png"/>', $uri.$pager->getNextPage().$tab);
			$navigation .= link_to('<img align="absmiddle" src="/images/last.png"/>', $uri.$pager->getLastPage().$tab);
	    	
			/*$navigation .= ' '.link_to(image_tag('/images/next.png', 'align=absmiddle'), $uri.$pager->getNextPage().$tab);
			$navigation .= link_to(image_tag('/images/last.png', 'align=absmiddle'), $uri.$pager->getLastPage().$tab);*/
	    }
	}
	return $navigation;
}